package com.xiaoyilin.consumer;

import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageProperties;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Service;

import java.io.UnsupportedEncodingException;

@Service
public class HeaderQueueConsumer {

    @RabbitListener(queues = "my.headers.queue")
    public void process(Message message) throws UnsupportedEncodingException {
        MessageProperties messageProperties = message.getMessageProperties();

        String contentType = messageProperties.getContentType();

        System.out.println("Header Queue Consumer:" + new String(message.getBody(), contentType));
    }

}
